package com.supermarket.service.impl;

import com.supermarket.entity.OperationLog;
import com.supermarket.mapper.OperationLogMapper;
import com.supermarket.service.OperationLogService;
import com.supermarket.vo.OperationLogVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class OperationLogServiceImpl implements OperationLogService {

    @Autowired
    private OperationLogMapper operationLogMapper;

    @Override
    public void recordLog(OperationLog operationLog) {
        operationLogMapper.insert(operationLog);
        log.info("记录操作日志：{}", operationLog);
    }

    @Override
    public List<OperationLogVo> getAllLogs() {
        return operationLogMapper.findAll();
    }

    @Override
    public List<OperationLogVo> getLogsByUserId(Long userId) {
        return operationLogMapper.findByUserId(userId);
    }
} 